using bdddoc.core;
using jpboodhoo.bdd.contexts;
using jpboodhoo.bdd.mbunit;
using jpboodhoo.bdd.mbunit.standard.observations;
using resharperupdate.core.controllers;
using resharperupdate.core.controllers.impl;
using resharperupdate.core.dto.impl;
using resharperupdate.core.services;
using Rhino.Mocks;

namespace resharperupdate.core.tests.controllers
{
    public class UpdaterControllerSpecs
    {
        [Concern(typeof(UpdaterController))]
        public abstract class concerns : observations_for_a_sut_with_a_contract<IUpdaterController, UpdaterController>
        {
            protected static IUpdaterTask tasks;
            protected static display_a_message display;
            protected static string title;
            protected static string status;

            private context c = () =>
                                    {
                                        display = the_dependency<display_a_message>();
                                        tasks = the_dependency<IUpdaterTask>();
                                    };
        }

        public class when_trying_to_install_the_same_version_you_have_installed : concerns
        {


            context c = () =>
                            {
                                tasks.Stub(x => x.latest_version()).Return(new Build {Installed = true});
                            };

            because b = () =>
            {
                                sut.display = (x, y) => title = x;
                                sut.status = x => status = x.ToString();
                                sut.install_latest();
            };

            it should_display_a_message = () => title.should_be_equal_to(UpdaterController.NO_NEW_VERSION);
        }
    }
}